import React, { Component } from 'react';
import { WhiteSpace } from 'antd-mobile'
import { editApi } from './editApi'
import Submit from '../../components/Submit'
import './edit.css'

class EditContent extends Component {
    constructor(props) {
        super(props);
        this.state = {
            username: '',
            truename: '',
            bank_address: '',
            mobile: '',
            secret_answer: '',
            pay_password: '',
            remark: ''
        }
        this.handleInputChange = this.handleInputChange.bind(this);
        this.handleSubmit = this.handleSubmit.bind(this);
    }
    componentDidMount() {
        editApi().then(res => {
            this.setState(res.data.current);
        })
    }
    handleInputChange = (e) => {
        let event = e.target;
        this.setState({
            [event.name]: event.value
        })
    }
    handleSubmit(e) {
        e.preventDefault();
        console.log(123132);
    }
    render() {
        return (
            <div className="editContent">
                <WhiteSpace size="lg" />
                <WhiteSpace size="lg" />
                <WhiteSpace size="lg" />
                <div className="contentItem">
                    <label>用户编号</label>
                    <input
                        placeholder="请输入用户编号"
                        name="username"
                        value={this.state.username}
                        onChange={this.handleInputChange}
                    />
                </div>
                <WhiteSpace size="lg" />
                <div className="contentItem">
                    <label>姓名</label>
                    <input
                        placeholder="请输入姓名"
                        name="truename"
                        value={this.state.truename}
                        onChange={this.handleInputChange}
                    />
                </div>
                <WhiteSpace size="lg" />
                <div className="contentItem">
                    <label>USDT地址</label>
                    <input
                        placeholder="请输入USDT地址"
                        name="bank_address"
                        value={this.state.bank_address}
                        onChange={this.handleInputChange}
                    />
                </div>
                <WhiteSpace size="lg" />
                <div className="contentItem">
                    <label>移动电话</label>
                    <input
                        placeholder="请输入移动电话"
                        name="mobile"
                        value={this.state.mobile}
                        onChange={this.handleInputChange}
                    />
                </div>
                <WhiteSpace size="lg" />
                <div className="contentItem">
                    <label>密保问题</label>
                    <input placeholder="请选择密保问题" />
                </div>
                <WhiteSpace size="lg" />
                <div className="contentItem">
                    <label>密保答案</label>
                    <input
                        placeholder="请输入密保答案"
                        name="secret_answer"
                        value={this.state.secret_answer}
                        onChange={this.handleInputChange}
                    />
                </div>
                <WhiteSpace size="lg" />
                <div className="contentItem">
                    <label>安全密码</label>
                    <input
                        placeholder="请输入安全密码"
                        type="password"
                        name="pay_password"
                        value={this.state.pay_password}
                        onChange={this.handleInputChange}
                    />
                </div>
                <WhiteSpace size="lg" />
                <div className="contentItem">
                    <label>备注</label>
                    <textarea
                        placeholder="请输入备注"
                        resize='none'
                        name="remark"
                        value={this.state.remark}
                        onChange={this.handleInputChange}
                    />
                </div>
                <Submit title="提交" onsubmit={this.handleSubmit} />
            </div>
        );
    }
}

export default EditContent;